import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 1.导入组件
import login from '@/views/user/login.vue'
import index from '@/views/home/index.vue'
import mainCount from '@/views/home/mainCount.vue'
import articleCategory from '@/views/article/articleCategory.vue'
import articleList from '@/views/article/articleList.vue'
import articleRelease from '@/views/article/articleRelease.vue'
import comment from '@/views/comment/comment.vue'
import user from '@/views/user/user.vue'


// 2.设置路由规则
const routes = [
 {
   name:'login',
   path:'/login',
   component:login
 },
 {
  name:'index',
  path:'/index',
  component:index,
  children:[
    {
      name:'mainCount',
      path:'/mainCount',
      component:mainCount
    },
    {
      name:'articleCategory',
      path:'/articleCategory',
      component:articleCategory
    },
    {
      name:'articleList',
      path:'/articleList',
      component:articleList
    },
    {
      name:'articleRelease',
      path:'/articleRelease',
      component:articleRelease
    },
    {
      name:'comment',
      path:'/comment',
      component:comment
    },
    {
      name:'user',
      path:'/user',
      component:user
    },
    // 二级路由输入 / ,则重定向到/mainCount
    {
      path:'/',
      redirect:'/mainCount'
    }
  ]
},
// 一级路由输入 / ,则重定向到/index
{
  path:'/',
  redirect:'/index'
}
]

// 3.创建路由对象
const router = new VueRouter({
  routes
})

// 4.导出,挂载到vue实例
export default router
